import json
import requests
from DrissionPage import ChromiumPage

dp = ChromiumPage().latest_tab
dp.listen.start("web/aweme/post/")
dp.get("https://www.douyin.com/user/MS4wLjABAAAAZQ1eb8-saUwzSmP4H6ZulCeYm0tjEdRyur0-hZedEscyCcM50l8G5ssyg8eWH9Oy?from_tab_name=main")
headers = {
    "user-agent":"Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Mobile Safari/537.36",
    "referer":"https://www.douyin.com/"
}
res = dp.listen.wait()
data = res.response.body
count = 0
for item in data['aweme_list']:
    url = item['video']['play_addr']['url_list'][0]
    res = requests.get(url,headers=headers)
    with open(f"./屎国一/{count}.{'mp3' if url.find('.mp3') >= 0 else 'mp4'}", "wb") as f:
        f.write(res.content)
    count += 1

